﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

using CE.User;
using CE.Global;
using CE.Provider;
using CE.Database;
public partial class personal_accident_ViewCompletedPersonalAccidentDetail : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session[CE.Global.General.UserId] != null && Session[CE.Global.General.UserTypeId] != null)
        {
            if (Convert.ToInt32(Session[CE.Global.General.UserTypeId]) !=
                Convert.ToInt32(CE.Global.CEUserType.Customer) && Convert.ToInt32(Session[CE.Global.General.UserTypeId]) !=
                Convert.ToInt32(CE.Global.CEUserType.Provider))
            {
                Response.Redirect("~/car-insurance/login.aspx");
            }
        }
        else
        {
            Response.Redirect("~/car-insurance/login.aspx");
        }
        if (!IsPostBack)
        {
            divNoOfChilds.Visible = false;
            divSpouse.Visible = false;
            divChilds.Visible = false;
            divChild1.Visible = false;
            divChild2.Visible = false;
            divChild3.Visible = false;
            divChild4.Visible = false;
            divChild5.Visible = false;

            if (Page.Request.Params["ResultId"] != null)
            {
                Int64 _tempResultId = 0;
                Int64 _PAId = 0;
                Int64 _SelectedId = 0;
                string _providerId = "0";
                Int64[] _results = new Int64[2];
                if (Int64.TryParse(Page.Request.Params["ResultId"], out _tempResultId))
                {
                    _results = CheckCompleteStatus(_tempResultId);
                    _PAId = _results[0];
                    _SelectedId = _results[1];

                    MyDatabase _db = new MyDatabase();
                    string strSql = "SELECT ProviderCompanyId FROM tblPAInsuranceSelectItem WHERE PAId = " + _PAId + " AND PASelectItemId = " + _SelectedId;
                    _providerId = _db.ExecuteScalarSqlStatement(strSql).ToString();
                    if (_providerId != "0")
                    {
                        ShowDetails(_PAId, Convert.ToInt64(_providerId.ToString()));
                    }
                    else
                    {
                        Response.Redirect("~/user/viewresulthistory.aspx");
                    }
                }
                else
                {
                    Response.Redirect("~/user/viewresulthistory.aspx");
                }
            }
            else
            {
                Response.Redirect("~/user/viewresulthistory.aspx");
            }
        }
    }

    private Int64[] CheckCompleteStatus(Int64 _resultId)
    {
        UserResultHistory _result = new UserResultHistory();
        UserResultHistoryDB _resultdb = new UserResultHistoryDB();
        Int64[] Result = new Int64[2]; 
        _result = _resultdb.GetResultHistory(Convert.ToInt64(Session[General.UserId].ToString()), _resultId);
        if (_result != null && _result.IsComplete)
        {
            Result[0] = _result.ID1;
            Result[1] = _result.ID2;
        }

        return Result;
    }

    private void ShowDetails(Int64 PAId, Int64 ProviderId)
    {
        divSpouseNationality.Visible = true;
        divChildNationality1.Visible = true;
        divChildNationality2.Visible = true;
        divChildNationality3.Visible = true;
        divChildNationality4.Visible = true;
        divChildNationality5.Visible = true;

        string _refNo = General.GetRefNumber(PAId);
        DataSet _dsProposal = new DataSet();
        ProposalDownloadDB _proposaldownloaddb = new ProposalDownloadDB();
        if (ProviderId == 29)
        {
            _dsProposal = _proposaldownloaddb.GetLibertyProposal(PAId, "PA");
            if (_dsProposal != null && _dsProposal.Tables[0].Rows.Count > 0)
            {
                string _covertype = _dsProposal.Tables[0].Rows[0]["CoverType"].ToString();
                if (_covertype == "IND")
                {
                    divSpouse.Visible = false;
                    lblCoverType.Text = "Individual";
                }
                else if (_covertype == "INDSP")
                {
                    divSpouse.Visible = true;
                    lblCoverType.Text = "Individual & Spouse";
                }
                else if (_covertype == "INDCHD")
                {
                    divSpouse.Visible = false;
                    lblCoverType.Text = "Individual & Children";
                }
                else if (_covertype == "INDSPCHD")
                {
                    divSpouse.Visible = true;
                    lblCoverType.Text = "Individual, Spouse & Children";
                }
                lblQuoteTitle.Text = "Quote Ref No : PAL" + _refNo + " - Personal Accidents (" + lblCoverType.Text.Trim() + ")";
                lblPlanName.Text = _dsProposal.Tables[0].Rows[0]["PlanName"].ToString();
                lblInsurer.Text = "Liberty Insurance";
                lblTotalPremium.Text = "$ " + Convert.ToSingle(_dsProposal.Tables[0].Rows[0]["AnnualPremium"].ToString()).ToString("#.00");
                lblName.Text = _dsProposal.Tables[0].Rows[0]["Name"].ToString();
                lblGender.Text = _dsProposal.Tables[0].Rows[0]["Gender"].ToString();
                lblBirthday.Text = _dsProposal.Tables[0].Rows[0]["DOB"].ToString();
                lblOccupation.Text = _dsProposal.Tables[0].Rows[0]["Description"].ToString();
                lblAddress.Text = "#" + _dsProposal.Tables[0].Rows[0]["UnitNo"].ToString()
                                      + "-" + _dsProposal.Tables[0].Rows[0]["HomeNo"].ToString() + "<br />"
                                      + _dsProposal.Tables[0].Rows[0]["Address"].ToString();
                lblContactNo.Text = _dsProposal.Tables[0].Rows[0]["MobileNo"].ToString();
                lblNRICNo.Text = _dsProposal.Tables[0].Rows[0]["NRICNo"].ToString();
                lblNationality.Text = _dsProposal.Tables[0].Rows[0]["Nationality"].ToString();

                if (_covertype == "INDSP" || _covertype == "INDSPCHD")
                {
                    divSpouse.Visible = true;
                    lblSpouseName.Text = _dsProposal.Tables[1].Rows[0]["SpouseName"].ToString();
                    lblSpouseNRIC.Text = _dsProposal.Tables[1].Rows[0]["SpouseNRICNo"].ToString();
                    lblSpouseBirthday.Text = _dsProposal.Tables[1].Rows[0]["SDOB"].ToString();
                    lblSpouseNationality.Text = _dsProposal.Tables[1].Rows[0]["SpouseNationality"].ToString();
                    lblSpouseOccupation.Text = _dsProposal.Tables[1].Rows[0]["Description"].ToString();
                }

                string _noofchild = _dsProposal.Tables[0].Rows[0]["NoOfChild"].ToString();
                lblNoOfChilds.Text = _noofchild.ToString();
                int _childcount = Convert.ToInt32(_noofchild);
                string[] _childname = new string[_childcount];
                string[] _childdob = new string[_childcount];
                string[] _childnationality = new string[_childcount];
                string[] _childnric = new string[_childcount];
                string[] _childrelation = new string[_childcount];
                string[] _childgender = new string[_childcount];
                if (_childcount > 0)
                {
                    divNoOfChilds.Visible = true;
                    divChilds.Visible = true;
                    for (int i = 0; i < _childcount; i++)
                    {
                        if (_covertype == "INDSPCHD")
                        {
                            _childname[i] = _dsProposal.Tables[2].Rows[i]["Name"].ToString();
                            _childdob[i] = _dsProposal.Tables[2].Rows[i]["CDOB"].ToString();
                            _childnationality[i] = _dsProposal.Tables[2].Rows[i]["Nationality"].ToString();
                            _childnric[i] = _dsProposal.Tables[2].Rows[i]["NRICNo"].ToString();
                            _childrelation[i] = _dsProposal.Tables[2].Rows[i]["Relation"].ToString();
                            _childgender[i] = _dsProposal.Tables[2].Rows[i]["Gender"].ToString();
                        }
                        else if (_covertype == "INDCHD")
                        {
                            _childname[i] = _dsProposal.Tables[1].Rows[i]["Name"].ToString();
                            _childdob[i] = _dsProposal.Tables[1].Rows[i]["CDOB"].ToString();
                            _childnationality[i] = _dsProposal.Tables[1].Rows[i]["Nationality"].ToString();
                            _childnric[i] = _dsProposal.Tables[1].Rows[i]["NRICNo"].ToString();
                            _childrelation[i] = _dsProposal.Tables[1].Rows[i]["Relation"].ToString();
                            _childgender[i] = _dsProposal.Tables[1].Rows[i]["Gender"].ToString();
                        }
                    }
                }
                if (_childcount > 0)
                {
                    divChild1.Visible = true;
                    lblChildName1.Text =  _childname[0].ToString();
                    lblChildBirthday1.Text = _childdob[0].ToString();
                    lblChildGender1.Text = _childgender[0].ToString();
                    lblChildNRIC1.Text = _childnric[0].ToString();
                    lblChildNationality1.Text = _childnationality[0].ToString();
                }
                if (_childcount > 1)
                {
                    divChild2.Visible = true;
                    lblChildName2.Text = _childname[1].ToString();
                    lblChildBirthday2.Text = _childdob[1].ToString();
                    lblChildGender2.Text = _childgender[1].ToString();
                    lblChildNRIC2.Text = _childnric[1].ToString();
                    lblChildNationality2.Text = _childnationality[1].ToString();
                }
                if (_childcount > 2)
                {
                    divChild3.Visible = true;
                    lblChildName3.Text = _childname[2].ToString();
                    lblChildBirthday3.Text = _childdob[2].ToString();
                    lblChildGender3.Text = _childgender[2].ToString();
                    lblChildNRIC3.Text = _childnric[2].ToString();
                    lblChildNationality3.Text = _childnationality[2].ToString();
                }
                if (_childcount > 3)
                {
                    divChild4.Visible = true;
                    lblChildName4.Text = _childname[3].ToString();
                    lblChildBirthday4.Text = _childdob[3].ToString();
                    lblChildGender4.Text = _childgender[3].ToString();
                    lblChildNRIC4.Text = _childnric[3].ToString();
                    lblChildNationality4.Text = _childnationality[3].ToString();
                }
                if (_childcount > 4)
                {
                    divChild5.Visible = true;
                    lblChildName5.Text = _childname[4].ToString();
                    lblChildBirthday5.Text = _childdob[4].ToString();
                    lblChildGender5.Text = _childgender[4].ToString();
                    lblChildNRIC5.Text = _childnric[4].ToString();
                    lblChildNationality5.Text = _childnationality[4].ToString();
                }
            }
        }
        else if (ProviderId == 23)
        {
            _dsProposal = _proposaldownloaddb.GetHSBCProposal(PAId, "PA");
            if (_dsProposal != null && _dsProposal.Tables[0].Rows.Count > 0)
            {
                string _covertype = _dsProposal.Tables[0].Rows[0]["CoverType"].ToString();
                if (_covertype == "IND")
                {
                    divSpouse.Visible = false;
                    lblCoverType.Text = "Individual";
                }
                else if (_covertype == "INDSP")
                {
                    divSpouse.Visible = true;
                    lblCoverType.Text = "Individual & Spouse";
                }
                else if (_covertype == "INDCHD")
                {
                    divSpouse.Visible = false;
                    lblCoverType.Text = "Individual & Children";
                }
                else if (_covertype == "INDSPCHD")
                {
                    divSpouse.Visible = true;
                    lblCoverType.Text = "Individual, Spouse & Children";
                }
                lblQuoteTitle.Text = "Quote Ref No : PAH" + _refNo + " - Personal Accidents (" + lblCoverType.Text.Trim() + ")";
                lblPlanName.Text = _dsProposal.Tables[0].Rows[0]["PlanName"].ToString();
                lblInsurer.Text = "HSBC Insurance";
                lblTotalPremium.Text = "$ " + Convert.ToSingle(_dsProposal.Tables[0].Rows[0]["AnnualPremium"].ToString()).ToString("#.00");
                lblName.Text = _dsProposal.Tables[0].Rows[0]["Name"].ToString();
                lblGender.Text = _dsProposal.Tables[0].Rows[0]["Gender"].ToString();
                lblBirthday.Text = _dsProposal.Tables[0].Rows[0]["DOB"].ToString();
                lblOccupation.Text = _dsProposal.Tables[0].Rows[0]["Description"].ToString();
                lblAddress.Text = "#" + _dsProposal.Tables[0].Rows[0]["UnitNo"].ToString()
                                      + "-" + _dsProposal.Tables[0].Rows[0]["HomeNo"].ToString() + "<br />"
                                      + _dsProposal.Tables[0].Rows[0]["Address"].ToString();
                lblContactNo.Text = _dsProposal.Tables[0].Rows[0]["MobileNo"].ToString();
                lblNRICNo.Text = _dsProposal.Tables[0].Rows[0]["NRICNo"].ToString();
                lblNationality.Text = _dsProposal.Tables[0].Rows[0]["Nationality"].ToString();

                if (_covertype == "INDSP" || _covertype == "INDSPCHD")
                {
                    divSpouse.Visible = true;
                    lblSpouseName.Text = _dsProposal.Tables[1].Rows[0]["SpouseName"].ToString();
                    lblSpouseNRIC.Text = _dsProposal.Tables[1].Rows[0]["SpouseNRICNo"].ToString();
                    lblSpouseBirthday.Text = _dsProposal.Tables[1].Rows[0]["SDOB"].ToString();
                    lblSpouseNationality.Text = _dsProposal.Tables[1].Rows[0]["SpouseNationality"].ToString();
                    lblSpouseOccupation.Text = _dsProposal.Tables[1].Rows[0]["Description"].ToString();
                }

                string _noofchild = _dsProposal.Tables[0].Rows[0]["NoOfChild"].ToString();
                lblNoOfChilds.Text = _noofchild.ToString();
                int _childcount = Convert.ToInt32(_noofchild);
                if (_childcount > 0)
                {
                    divNoOfChilds.Visible = true;
                }
            }
        }
        else if (ProviderId == 34)
        {
            divSpouseNationality.Visible = false;
            divChildNationality1.Visible = false;
            divChildNationality2.Visible = false;
            divChildNationality3.Visible = false;
            divChildNationality4.Visible = false;
            divChildNationality5.Visible = false;
            _dsProposal = _proposaldownloaddb.GetChinaTaipingProposal(PAId, "PA");
            if (_dsProposal != null && _dsProposal.Tables[0].Rows.Count > 0)
            {
                string _covertype = _dsProposal.Tables[0].Rows[0]["CoverType"].ToString();
                if (_covertype == "IND")
                {
                    divSpouse.Visible = false;
                    lblCoverType.Text = "Individual";
                }
                else if (_covertype == "INDSP")
                {
                    divSpouse.Visible = true;
                    lblCoverType.Text = "Individual & Spouse";
                }
                else if (_covertype == "INDCHD")
                {
                    divSpouse.Visible = false;
                    lblCoverType.Text = "Individual & Children";
                }
                else if (_covertype == "INDSPCHD")
                {
                    divSpouse.Visible = true;
                    lblCoverType.Text = "Individual, Spouse & Children";
                }
                lblQuoteTitle.Text = "Quote Ref No : PAC" + _refNo + " - Personal Accidents (" + lblCoverType.Text.Trim() + ")";
                lblPlanName.Text = _dsProposal.Tables[0].Rows[0]["PlanName"].ToString();
                lblInsurer.Text = "China Taiping Insurance";
                lblTotalPremium.Text = "$ " + Convert.ToSingle(_dsProposal.Tables[0].Rows[0]["AnnualPremium"].ToString()).ToString("#.00");
                lblName.Text = _dsProposal.Tables[0].Rows[0]["Name"].ToString();
                lblGender.Text = _dsProposal.Tables[0].Rows[0]["Gender"].ToString();
                lblBirthday.Text = _dsProposal.Tables[0].Rows[0]["DOB"].ToString();
                lblOccupation.Text = _dsProposal.Tables[0].Rows[0]["Description"].ToString();
                lblAddress.Text = "#" + _dsProposal.Tables[0].Rows[0]["UnitNo"].ToString()
                                      + "-" + _dsProposal.Tables[0].Rows[0]["HomeNo"].ToString() + "<br />"
                                      + _dsProposal.Tables[0].Rows[0]["Address"].ToString();
                lblContactNo.Text = _dsProposal.Tables[0].Rows[0]["MobileNo"].ToString();
                lblNRICNo.Text = _dsProposal.Tables[0].Rows[0]["NRICNo"].ToString();
                lblNationality.Text = _dsProposal.Tables[0].Rows[0]["Nationality"].ToString();

                if (_covertype == "INDSP" || _covertype == "INDSPCHD")
                {
                    divSpouse.Visible = true;
                    lblSpouseName.Text = _dsProposal.Tables[1].Rows[0]["SpouseName"].ToString();
                    lblSpouseNRIC.Text = _dsProposal.Tables[1].Rows[0]["SpouseNRICNo"].ToString();
                    lblSpouseBirthday.Text = _dsProposal.Tables[1].Rows[0]["SDOB"].ToString();
                    lblSpouseOccupation.Text = _dsProposal.Tables[1].Rows[0]["Description"].ToString();
                }

                string _noofchild = _dsProposal.Tables[0].Rows[0]["NoOfChild"].ToString();
                lblNoOfChilds.Text = _noofchild.ToString();
                int _childcount = Convert.ToInt32(_noofchild);
                string[] _childname = new string[_childcount];
                string[] _childdob = new string[_childcount];
                //string[] _childnationality = new string[_childcount];
                string[] _childnric = new string[_childcount];
                //string[] _childrelation = new string[_childcount];
                string[] _childgender = new string[_childcount];
                if (_childcount > 0)
                {
                    divNoOfChilds.Visible = true;
                    divChilds.Visible = true;
                    for (int i = 0; i < _childcount; i++)
                    {
                        if (_covertype == "INDSPCHD")
                        {
                            _childname[i] = _dsProposal.Tables[2].Rows[i]["Name"].ToString();
                            _childdob[i] = _dsProposal.Tables[2].Rows[i]["CDOB"].ToString();
                            //_childnationality[i] = _dsProposal.Tables[2].Rows[i]["Nationality"].ToString();
                            _childnric[i] = _dsProposal.Tables[2].Rows[i]["NRICNo"].ToString();
                            //_childrelation[i] = _dsProposal.Tables[2].Rows[i]["Relation"].ToString();
                            _childgender[i] = _dsProposal.Tables[2].Rows[i]["Gender"].ToString();
                        }
                        else if (_covertype == "INDCHD")
                        {
                            _childname[i] = _dsProposal.Tables[1].Rows[i]["Name"].ToString();
                            _childdob[i] = _dsProposal.Tables[1].Rows[i]["CDOB"].ToString();
                           // _childnationality[i] = _dsProposal.Tables[1].Rows[i]["Nationality"].ToString();
                            _childnric[i] = _dsProposal.Tables[1].Rows[i]["NRICNo"].ToString();
                            //_childrelation[i] = _dsProposal.Tables[1].Rows[i]["Relation"].ToString();
                            _childgender[i] = _dsProposal.Tables[1].Rows[i]["Gender"].ToString();
                        }
                    }
                }
                if (_childcount > 0)
                {
                    divChild1.Visible = true;
                    lblChildName1.Text = _childname[0].ToString();
                    lblChildBirthday1.Text = _childdob[0].ToString();
                    lblChildGender1.Text = _childgender[0].ToString();
                    lblChildNRIC1.Text = _childnric[0].ToString();
                    //lblChildNationality1.Text = _childnationality[0].ToString();
                }
                if (_childcount > 1)
                {
                    divChild2.Visible = true;
                    lblChildName2.Text = _childname[1].ToString();
                    lblChildBirthday2.Text = _childdob[1].ToString();
                    lblChildGender2.Text = _childgender[1].ToString();
                    lblChildNRIC2.Text = _childnric[1].ToString();
                    //lblChildNationality2.Text = _childnationality[1].ToString();
                }
                if (_childcount > 2)
                {
                    divChild3.Visible = true;
                    lblChildName3.Text = _childname[2].ToString();
                    lblChildBirthday3.Text = _childdob[2].ToString();
                    lblChildGender3.Text = _childgender[2].ToString();
                    lblChildNRIC3.Text = _childnric[2].ToString();
                    //lblChildNationality3.Text = _childnationality[2].ToString();
                }
                if (_childcount > 3)
                {
                    divChild4.Visible = true;
                    lblChildName4.Text = _childname[3].ToString();
                    lblChildBirthday4.Text = _childdob[3].ToString();
                    lblChildGender4.Text = _childgender[3].ToString();
                    lblChildNRIC4.Text = _childnric[3].ToString();
                    //lblChildNationality4.Text = _childnationality[3].ToString();
                }
                if (_childcount > 4)
                {
                    divChild5.Visible = true;
                    lblChildName5.Text = _childname[4].ToString();
                    lblChildBirthday5.Text = _childdob[4].ToString();
                    lblChildGender5.Text = _childgender[4].ToString();
                    lblChildNRIC5.Text = _childnric[4].ToString();
                    //lblChildNationality5.Text = _childnationality[4].ToString();
                }
            }
        }
        else if (ProviderId == 35)
        {
            divSpouseNationality.Visible = false;
            divChildNationality1.Visible = false;
            divChildNationality2.Visible = false;
            divChildNationality3.Visible = false;
            divChildNationality4.Visible = false;
            divChildNationality5.Visible = false;
            _dsProposal = _proposaldownloaddb.GetEQProposal(PAId, "PA");
            if (_dsProposal != null && _dsProposal.Tables[0].Rows.Count > 0)
            {
                string _covertype = _dsProposal.Tables[0].Rows[0]["CoverType"].ToString();
                if (_covertype == "IND")
                {
                    divSpouse.Visible = false;
                    lblCoverType.Text = "Individual";
                }
                else if (_covertype == "INDSP")
                {
                    divSpouse.Visible = true;
                    lblCoverType.Text = "Individual & Spouse";
                }
                else if (_covertype == "INDCHD")
                {
                    divSpouse.Visible = false;
                    lblCoverType.Text = "Individual & Children";
                }
                else if (_covertype == "INDSPCHD")
                {
                    divSpouse.Visible = true;
                    lblCoverType.Text = "Individual, Spouse & Children";
                }
                lblQuoteTitle.Text = "Quote Ref No : PAQ" + _refNo + " - Personal Accidents (" + lblCoverType.Text.Trim() + ")";
                lblPlanName.Text = _dsProposal.Tables[0].Rows[0]["PlanName"].ToString();
                lblInsurer.Text = "EQ Insurance";
                lblTotalPremium.Text = "$ " + Convert.ToSingle(_dsProposal.Tables[0].Rows[0]["AnnualPremium"].ToString()).ToString("#.00");
                lblName.Text = _dsProposal.Tables[0].Rows[0]["Name"].ToString();
                lblGender.Text = _dsProposal.Tables[0].Rows[0]["Gender"].ToString();
                lblBirthday.Text = _dsProposal.Tables[0].Rows[0]["DOB"].ToString();
                lblOccupation.Text = _dsProposal.Tables[0].Rows[0]["Description"].ToString();
                lblAddress.Text = "#" + _dsProposal.Tables[0].Rows[0]["UnitNo"].ToString()
                                      + "-" + _dsProposal.Tables[0].Rows[0]["HomeNo"].ToString() + "<br />"
                                      + _dsProposal.Tables[0].Rows[0]["Address"].ToString();
                lblContactNo.Text = _dsProposal.Tables[0].Rows[0]["MobileNo"].ToString();
                lblNRICNo.Text = _dsProposal.Tables[0].Rows[0]["NRICNo"].ToString();
                lblNationality.Text = _dsProposal.Tables[0].Rows[0]["Nationality"].ToString();

                if (_covertype == "INDSP" || _covertype == "INDSPCHD")
                {
                    divSpouse.Visible = true;
                    lblSpouseName.Text = _dsProposal.Tables[1].Rows[0]["SpouseName"].ToString();
                    lblSpouseNRIC.Text = _dsProposal.Tables[1].Rows[0]["SpouseNRICNo"].ToString();
                    lblSpouseBirthday.Text = _dsProposal.Tables[1].Rows[0]["SDOB"].ToString();
                    lblSpouseOccupation.Text = _dsProposal.Tables[1].Rows[0]["Description"].ToString();
                }

                string _noofchild = _dsProposal.Tables[0].Rows[0]["NoOfChild"].ToString();
                lblNoOfChilds.Text = _noofchild.ToString();
                int _childcount = Convert.ToInt32(_noofchild);
                string[] _childname = new string[_childcount];
                string[] _childdob = new string[_childcount];
                //string[] _childnationality = new string[_childcount];
                string[] _childnric = new string[_childcount];
                //string[] _childrelation = new string[_childcount];
                string[] _childgender = new string[_childcount];
                if (_childcount > 0)
                {
                    divNoOfChilds.Visible = true;
                    divChilds.Visible = true;
                    for (int i = 0; i < _childcount; i++)
                    {
                        if (_covertype == "INDSPCHD")
                        {
                            _childname[i] = _dsProposal.Tables[2].Rows[i]["Name"].ToString();
                            _childdob[i] = _dsProposal.Tables[2].Rows[i]["CDOB"].ToString();
                            //_childnationality[i] = _dsProposal.Tables[2].Rows[i]["Nationality"].ToString();
                            _childnric[i] = _dsProposal.Tables[2].Rows[i]["NRICNo"].ToString();
                            //_childrelation[i] = _dsProposal.Tables[2].Rows[i]["Relation"].ToString();
                            _childgender[i] = _dsProposal.Tables[2].Rows[i]["Gender"].ToString();
                        }
                        else if (_covertype == "INDCHD")
                        {
                            _childname[i] = _dsProposal.Tables[1].Rows[i]["Name"].ToString();
                            _childdob[i] = _dsProposal.Tables[1].Rows[i]["CDOB"].ToString();
                            // _childnationality[i] = _dsProposal.Tables[1].Rows[i]["Nationality"].ToString();
                            _childnric[i] = _dsProposal.Tables[1].Rows[i]["NRICNo"].ToString();
                            //_childrelation[i] = _dsProposal.Tables[1].Rows[i]["Relation"].ToString();
                            _childgender[i] = _dsProposal.Tables[1].Rows[i]["Gender"].ToString();
                        }
                    }
                }
                if (_childcount > 0)
                {
                    divChild1.Visible = true;
                    lblChildName1.Text = _childname[0].ToString();
                    lblChildBirthday1.Text = _childdob[0].ToString();
                    lblChildGender1.Text = _childgender[0].ToString();
                    lblChildNRIC1.Text = _childnric[0].ToString();
                    //lblChildNationality1.Text = _childnationality[0].ToString();
                }
                if (_childcount > 1)
                {
                    divChild2.Visible = true;
                    lblChildName2.Text = _childname[1].ToString();
                    lblChildBirthday2.Text = _childdob[1].ToString();
                    lblChildGender2.Text = _childgender[1].ToString();
                    lblChildNRIC2.Text = _childnric[1].ToString();
                    //lblChildNationality2.Text = _childnationality[1].ToString();
                }
                if (_childcount > 2)
                {
                    divChild3.Visible = true;
                    lblChildName3.Text = _childname[2].ToString();
                    lblChildBirthday3.Text = _childdob[2].ToString();
                    lblChildGender3.Text = _childgender[2].ToString();
                    lblChildNRIC3.Text = _childnric[2].ToString();
                    //lblChildNationality3.Text = _childnationality[2].ToString();
                }
                if (_childcount > 3)
                {
                    divChild4.Visible = true;
                    lblChildName4.Text = _childname[3].ToString();
                    lblChildBirthday4.Text = _childdob[3].ToString();
                    lblChildGender4.Text = _childgender[3].ToString();
                    lblChildNRIC4.Text = _childnric[3].ToString();
                    //lblChildNationality4.Text = _childnationality[3].ToString();
                }
                if (_childcount > 4)
                {
                    divChild5.Visible = true;
                    lblChildName5.Text = _childname[4].ToString();
                    lblChildBirthday5.Text = _childdob[4].ToString();
                    lblChildGender5.Text = _childgender[4].ToString();
                    lblChildNRIC5.Text = _childnric[4].ToString();
                    //lblChildNationality5.Text = _childnationality[4].ToString();
                }
            }
        }
        else if (ProviderId == 30)
        {
            divSpouseNationality.Visible = false;
            divChildNationality1.Visible = false;
            divChildNationality2.Visible = false;
            divChildNationality3.Visible = false;
            divChildNationality4.Visible = false;
            divChildNationality5.Visible = false;
            _dsProposal = _proposaldownloaddb.GetEtiqaProposal(PAId, "PA");
            if (_dsProposal != null && _dsProposal.Tables[0].Rows.Count > 0)
            {
                string _covertype = _dsProposal.Tables[0].Rows[0]["CoverType"].ToString();
                if (_covertype == "IND")
                {
                    divSpouse.Visible = false;
                    lblCoverType.Text = "Individual";
                }
                else if (_covertype == "INDSP")
                {
                    divSpouse.Visible = true;
                    lblCoverType.Text = "Individual & Spouse";
                }
                else if (_covertype == "INDCHD")
                {
                    divSpouse.Visible = false;
                    lblCoverType.Text = "Individual & Children";
                }
                else if (_covertype == "INDSPCHD")
                {
                    divSpouse.Visible = true;
                    lblCoverType.Text = "Individual, Spouse & Children";
                }
                lblQuoteTitle.Text = "Quote Ref No : PAE" + _refNo + " - Personal Accidents (" + lblCoverType.Text.Trim() + ")";
                lblPlanName.Text = _dsProposal.Tables[0].Rows[0]["PlanName"].ToString();
                lblInsurer.Text = "Etiqa Insurance";
                lblTotalPremium.Text = "$ " + Convert.ToSingle(_dsProposal.Tables[0].Rows[0]["AnnualPremium"].ToString()).ToString("#.00");
                lblName.Text = _dsProposal.Tables[0].Rows[0]["Name"].ToString();
                lblGender.Text = _dsProposal.Tables[0].Rows[0]["Gender"].ToString();
                lblBirthday.Text = _dsProposal.Tables[0].Rows[0]["DOB"].ToString();
                lblOccupation.Text = _dsProposal.Tables[0].Rows[0]["Description"].ToString();
                lblAddress.Text = "#" + _dsProposal.Tables[0].Rows[0]["UnitNo"].ToString()
                                      + "-" + _dsProposal.Tables[0].Rows[0]["HomeNo"].ToString() + "<br />"
                                      + _dsProposal.Tables[0].Rows[0]["Address"].ToString();
                lblContactNo.Text = _dsProposal.Tables[0].Rows[0]["MobileNo"].ToString();
                lblNRICNo.Text = _dsProposal.Tables[0].Rows[0]["NRICNo"].ToString();
                lblNationality.Text = _dsProposal.Tables[0].Rows[0]["Nationality"].ToString();

                if (_covertype == "INDSP" || _covertype == "INDSPCHD")
                {
                    divSpouse.Visible = true;
                    lblSpouseName.Text = _dsProposal.Tables[1].Rows[0]["SpouseName"].ToString();
                    lblSpouseNRIC.Text = _dsProposal.Tables[1].Rows[0]["SpouseNRICNo"].ToString();
                    lblSpouseBirthday.Text = _dsProposal.Tables[1].Rows[0]["SDOB"].ToString();
                    lblSpouseOccupation.Text = _dsProposal.Tables[1].Rows[0]["Description"].ToString();
                }

                string _noofchild = _dsProposal.Tables[0].Rows[0]["NoOfChild"].ToString();
                lblNoOfChilds.Text = _noofchild.ToString();
                int _childcount = Convert.ToInt32(_noofchild);
                string[] _childname = new string[_childcount];
                string[] _childdob = new string[_childcount];
                //string[] _childnationality = new string[_childcount];
                string[] _childnric = new string[_childcount];
                //string[] _childrelation = new string[_childcount];
                string[] _childgender = new string[_childcount];
                if (_childcount > 0)
                {
                    divNoOfChilds.Visible = true;
                    divChilds.Visible = true;
                    for (int i = 0; i < _childcount; i++)
                    {
                        if (_covertype == "INDSPCHD")
                        {
                            _childname[i] = _dsProposal.Tables[2].Rows[i]["Name"].ToString();
                            _childdob[i] = _dsProposal.Tables[2].Rows[i]["CDOB"].ToString();
                            //_childnationality[i] = _dsProposal.Tables[2].Rows[i]["Nationality"].ToString();
                            _childnric[i] = _dsProposal.Tables[2].Rows[i]["NRICNo"].ToString();
                            //_childrelation[i] = _dsProposal.Tables[2].Rows[i]["Relation"].ToString();
                            _childgender[i] = _dsProposal.Tables[2].Rows[i]["Gender"].ToString();
                        }
                        else if (_covertype == "INDCHD")
                        {
                            _childname[i] = _dsProposal.Tables[1].Rows[i]["Name"].ToString();
                            _childdob[i] = _dsProposal.Tables[1].Rows[i]["CDOB"].ToString();
                            // _childnationality[i] = _dsProposal.Tables[1].Rows[i]["Nationality"].ToString();
                            _childnric[i] = _dsProposal.Tables[1].Rows[i]["NRICNo"].ToString();
                            //_childrelation[i] = _dsProposal.Tables[1].Rows[i]["Relation"].ToString();
                            _childgender[i] = _dsProposal.Tables[1].Rows[i]["Gender"].ToString();
                        }
                    }
                }
                if (_childcount > 0)
                {
                    divChild1.Visible = true;
                    lblChildName1.Text = _childname[0].ToString();
                    lblChildBirthday1.Text = _childdob[0].ToString();
                    lblChildGender1.Text = _childgender[0].ToString();
                    lblChildNRIC1.Text = _childnric[0].ToString();
                    //lblChildNationality1.Text = _childnationality[0].ToString();
                }
                if (_childcount > 1)
                {
                    divChild2.Visible = true;
                    lblChildName2.Text = _childname[1].ToString();
                    lblChildBirthday2.Text = _childdob[1].ToString();
                    lblChildGender2.Text = _childgender[1].ToString();
                    lblChildNRIC2.Text = _childnric[1].ToString();
                    //lblChildNationality2.Text = _childnationality[1].ToString();
                }
                if (_childcount > 2)
                {
                    divChild3.Visible = true;
                    lblChildName3.Text = _childname[2].ToString();
                    lblChildBirthday3.Text = _childdob[2].ToString();
                    lblChildGender3.Text = _childgender[2].ToString();
                    lblChildNRIC3.Text = _childnric[2].ToString();
                    //lblChildNationality3.Text = _childnationality[2].ToString();
                }
                if (_childcount > 3)
                {
                    divChild4.Visible = true;
                    lblChildName4.Text = _childname[3].ToString();
                    lblChildBirthday4.Text = _childdob[3].ToString();
                    lblChildGender4.Text = _childgender[3].ToString();
                    lblChildNRIC4.Text = _childnric[3].ToString();
                    //lblChildNationality4.Text = _childnationality[3].ToString();
                }
                if (_childcount > 4)
                {
                    divChild5.Visible = true;
                    lblChildName5.Text = _childname[4].ToString();
                    lblChildBirthday5.Text = _childdob[4].ToString();
                    lblChildGender5.Text = _childgender[4].ToString();
                    lblChildNRIC5.Text = _childnric[4].ToString();
                    //lblChildNationality5.Text = _childnationality[4].ToString();
                }
            }
        }
    }

    protected void ibtnBack_Click(object sender, ImageClickEventArgs e)
    {
        Response.Redirect("~/user/viewresulthistory.aspx");
    }
}
